<?php

require_once 'Pipes/Exception.php';

class Pipes_FileSystem_File
{
	private $_fullPath = null;
	private $_file = null;

	public function __construct($file, $path = null) 
	{
		$this->_fullPath = realpath($path . $file);
		$this->_file = $file;
	}
	
	public function exists() {
		return file_exists($this->_fullPath);
	}
	
	public function requireOnce() {
		if (!$this->exists()) {
			throw new Pipes_Exception("unknown file [{$this->_file}]");
		}
		
		require_once $this->_fullPath;
	}

	public function __get($key) {
		$return = null;
		switch ($key) {
			case 'fullPath':
			case 'file' :
				$realKey = '_' . $key;
				$return = $this->$realKey;
				break;
		}
		return $return;
	}
}
